pp108 : Using XSLT API

Using XSLT API

This topic describes the usage of XSLT API(s).


The XSLT mechanism is used in identifying, updating, and transforming specific portions of an XML document.

XSLT uses the XSL and creates an XML object that needs to be transformed to an XML format that is based on another XML schema. After using XPath to identify the XML fragment to be transformed, XSLT is used to finally transform the XML document.
To use XSLT, follow these instructions:

  1. Create an XSL object from the XSL map. XSL map can be in the form of a string or can be inside a file
  2. Perform the mapping using the XSLT object
  3. Delete the XSLT object (if used from native layer)

    To understand the procedure, consider the following example:
    try { Document oDocument = new Document(); int iXml = oDocument.load("birds.xml"); XSLT oXSL = XSLT.parseFromFile("birds.xsl"); if(oXSL != null) { String iTransformedXML = oXSL.xslTransformToString(iXml); oXSL.delete(); } } catch (XMLException e) { e.printStackTrace(); }

Related reference

XSLT Architecture

Related information

Overview of XSLT